﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Data;

namespace personalplaner.common.controls
{
	/// <remarks>
	/// var col = new DataGridPlanItemTemplateColumn
	///	{
	///		IsReadOnly = true,
	///		CanUserReorder = false,
	///
	///		Header = column.Datum.Day,
	///
	///		ColumnName = string.Format("[{0}]", index),
	///		CellTemplate = (DataTemplate)FindResource("PART_CellTemplate")
	///	};
	/// </remarks>

	/// <summary>
	/// 
	/// </summary>
	public class DataGridPlanItemTemplateColumn : DataGridTemplateColumn
	{

        public DataGridPlanItemTemplateColumn()
        {
            /*
            <Grid>
                <Border Background="{Binding BackgroundColor, Converter={StaticResource colorToBrush}}" Focusable="False"/>
                <Border Background="{Binding Color, Converter={StaticResource colorToBrush}}">
                    <Button Style="{StaticResource TransparentButtonStyle}" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:PlanGrid}, AncestorLevel=1}, Path=Command}" CommandParameter="{Binding}" >
                        <TextBlock Text="{Binding Name}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,1,2,1" FontWeight="DemiBold" FontSize="10"/>
                    </Button>
                </Border>
            </Grid>
            */
        }

		public string ColumnName
		{
			get;
			set;
		}

		protected override System.Windows.FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
		{
			// The DataGridTemplateColumn uses ContentPresenter with your DataTemplate.
			ContentPresenter cp = (ContentPresenter)base.GenerateElement(cell, dataItem);
			// Reset the Binding to the specific column. The default binding is to the DataRowView.
            BindingOperations.SetBinding(cp, ContentPresenter.ContentProperty, new Binding(this.ColumnName));
			return cp;
		}

	}
}
